package com.xxl.job.core.enums;

import com.xxl.job.core.constants.Constants;

/**
 * 统计名目
 * 用于数据共享统计
 */
public enum WebReportNames {
    APPLICATION_TOTAL(Constants.APPLICATION_TOTAL, "应用总计"),
    SUBSCRIBE_TOTAL(Constants.SUBSCRIBE_TOTAL, "订阅服务总计"),
    REQUEST_TOTAL(Constants.REQUEST_TOTAL, "服务调用总计"),
    SERVICE_TOTAL(Constants.SERVICE_TOTAL, "共享服务总计"),
    DEPARTMENT_TOTAL(Constants.DEPARTMENT_TOTAL, "部门总计"),

    APPLICATION_REQUEST_RANK(Constants.APPLICATION_REQUEST_RANK, "应用调用服务排名"),
    APPLICATION_SUBSCRIBE_RANK(Constants.APPLICATION_SUBSCRIBE_RANK, "应用订阅服务排名"),
    DEPARTMENT_REQUEST_RANK(Constants.DEPARTMENT_REQUEST_RANK, "部门调用服务排名"),
    DEPARTMENT_SUBSCRIBE_RANK(Constants.DEPARTMENT_SUBSCRIBE_RANK, "部门订阅服务排名"),
    AUTHORIZE_APPLICATION_RANK(Constants.AUTHORIZE_APPLICATION_RANK, "服务授权应用排名")
            ;

    WebReportNames(String name, String remark) {
        setName(name);
        setRemark(remark);
    }

    private String name;
    private String remark;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public static String getRemarkByName(String name) {
        if(name == null || "".equals(name)) {
            return "";
        }
        WebReportNames[] names = WebReportNames.values();
        for (WebReportNames n: names) {
            if(n.getName().equals(name)) {
                return n.getRemark();
            }
        }
        return "";
    }
}
